Responsive layout settings

Description

This is where you will find the settings that allow you to define rules that change the layout of the UX component based on the type of device on which the component is running, its orientation and window size (in the case of a desktop browser). Clicking on the Responsive layout settings property will open the following Genie.

images/resp.png

And here is an example of what can be done with with Responsive Layouts. The images below are the same list control viewed in two different layouts, one for when the phone is held vertically and the other for when it is held horizontally.

images/prop7.png
Vertical layout
images/prop9.png
Horizontal layout

The Responsive Layout Genie has three parts or 'steps'. Step 1 is to define different rules, Step 2 is to define different actions, and Step 3 is to define different properties for those actions. The Guide below describes how you can create a simple responsive layout.

Prelude: Make a List Control with Multiple Layouts.

It is necessary to have some multiple layouts defined for a control before being able to implement a responsive layout.

  1. Open the UX Builder. On the UX Controls page in the 'Data Controls' menu, click on the [List] option in order to add a list control to the component.

    images/pre.png
  2. Check the 'Mobile' Checkbox in the UX controls toolbar.

    images/pre2.png
  3. Highlight the List Control. In the List Properties section of the control Properties list, click on the 'List properties' property in order to open the List Builder

    images/pre3.png
  4. Open the Data Source pane of the List Builder. Set the Data Source Type to 'Static'.

    images/pre4.png
  5. Click the button next to the Static data property.

    images/pre5.png
  6. In the Static Choices dialog click the 'Sample data' button, lower left.

    images/pre6.png
  7. Select the 'Name and addresses (big data set)' option in the Sample Data dialog. Click OK and OK again to return to the List Builder.

    images/pre7.png
  8. Open the List Properties pane. Scroll down the list properties to the Multiple Layouts section. Check the 'Has multiple layouts' checkbox. The Multiple Layouts pane will appear.

    images/pre8.png
  9. Open the Multiple Layouts pane and highlight the Default layout.

    images/pre9.png
  10. Click the button next to the Layout name property. Change the 'Default' layout name to 'Horizontal'.

    images/pre10.png
  11. Check the Default layout checkbox.

    images/pre11.png
  12. Click the Add button. Create a new layout. Give the new layout the name 'Vertical' and choose the 'Column' type from the drop down. Click OK.

    images/pre12.png
  13. Open the List Layout pane. Choose the 'Horizontal (Columns)' layout option from the dropdown at the bottom of the pane.

    images/pre13.png
  14. Use the blue > arrow to move all of the Static Choices fields from the 'Available Fields' list to the 'Columns in List'.

    images/pre14.png
  15. In Layout dropdown select the 'Vertical (Columns)' option.

    images/pre15.png
  16. Use the blue > arrow to move the ContactName field and the Country field from the Available Fields list to the Columns in List section. Click OK to close the List Builder.

    images/pre16.png
  17. On the UX Controls page highlight the list control and open the Panels menu.

    images/pre17.png
  18. Click on the [Panel Card] option and in the Insert Panel dialog click the 'Insert Around' option.

    images/pre18.png
  19. The completed control.

    images/pre19.png

Step 1: Create a Rule

Rules are javascript expressions that evaluate to either true or false. These expressions can reference system fields, for example screen.width or screen.height.

  1. Open the UX Properties page.

    images/rule.png
  2. In the Responsive Layout Settings click the button next to the Responsive layout settings property to open the Responsive Layout Genie.

    images/rule2.png
  3. Click the Add Rule button on the Responsive Layout Genie.

    images/rule3.png
  4. Give the new rule a name in the 'Rule name' textbox. The name can be arbitrary but it should somewhat describe what the purpose of the rule is. This example uses the name 'landscape_rule'

    images/rule4.png
  5. Click on the Insert field button in the lower left of the Edit Rule dialog.

    images/rule5.png
  6. A list of all the system fields that you can reference will appear. Click on the 'screen.orientation' option to insert it into the Expression box.

    images/rule6.png
  7. Type == or click the 'Insert 'equals' operator button

    images/rule7.png
    '==' in Javascript tests whether the two sides of an expression are truthy. The word truthy is used because of Javascript's flexible definition regarding the values associated with different types of data. For example, when compared using a '==' operator the character '1' and the numeric value 1 will return true; '1' == 1. To test for strict equivalence Javascript uses the '===' operator.
  8. Type 'landscape' at the end of the expression and click OK.

    images/rule8.png
  9. Click the Add button again to add a second rule.

    images/rule9.png
  10. Name the rule 'portrait_rule' and give it the following expression, click OK:

    screen.orientation == 'portrait'
    images/rule10.png
  11. The finished rules:

    images/rule11.png

Step 2: Add and Action

  1. Click the 'Add Action' in the lower left corner of the Responsive Layout Genie.

    images/action.png
  2. Select the 'Select active layout in a List control' option. Click OK

    images/action2.png
  3. In the 'Select List' dialog click on the list control that was defined earlier, in this case 'list1'

    images/action3.png
  4. The new action should appear in your 'Actions' list.

    images/action4.png

Step 3: Define an Action Property

  1. Highlight the 'landscape_rule' Rule and the Action you just defined.

    images/prop.png
  2. In the Select Layout Settings section, click the button next to List Layout Name.

    images/prop2.png
  3. Select the Horizontal layout you defined.

    images/prop3.png
  4. Now highlight the 'portrait_rule' Rule and the 'Select active layout in a List control (list1)' action.

    images/prop4.png
  5. Return to the Select Layout Settings section and click the button next to List Layout Name.

    images/prop5.png
  6. Select the Vertical layout. Click OK.

    images/prop6.png
  7. Close the Responsive Layout Genie and run the component in either Live Preview or Working Preview. Here is the vertical layout with the two fields that were defined.

    images/prop7.png
  8. Alter the orientation of the device by selecting a different orientation in the dropdown. You should see the layout change. Here the horizontal layout is displayed with the many fields tightly grouped.

    images/prop8.png
  9. In order to better see the fields it is possible to go back to the list builder and adjust the horizontal layout's width and/or the number of fields it displays. In the example below the 'horizontal' layout has had some fields cut in the list builder's List Layout pane. The Width property in the List Properties section of the UX controls page has also been increased to 4.5.

    images/prop9.png